package cn.g31010.sip.model
{
	import cn.g31010.sip.vo.Room;
	
	import com.adobe.cairngorm.model.ModelLocator;
	
	import mx.collections.ArrayCollection;
	
	public class RoomModel implements ModelLocator
	{
		private static var modelLocator : RoomModel;
		
		public static function getInstance() : RoomModel 
		{
			if ( modelLocator == null ){
				modelLocator = new RoomModel();
			}
			return modelLocator;
	   }
	   
   		public function RoomModel() 
   		{
   			if ( RoomModel.modelLocator != null )
				throw new Error( "Only one ModelLocator instance should be instantiated" );	
   		}
   		
   		[Bindable]
   		public var currentRoom:Room;
   		
   		[Bindable]
   		public var rooms:ArrayCollection=new ArrayCollection();
   		
   		public function removeRoom(id:String):Room{
   			for(var i:int=0;i<rooms.length;i++){
   				if(rooms[i].id==id){
   					return rooms[i];
   				}
   			}
   			return null;
   		}
   		
   		public function addRoom(r:Room):void{
   			rooms.addItem(r);
   		}
	}
}